package Classic150;

public class 判断子序列 {
    /*
        快慢双指针
     */
    public boolean isSubsequence(String s, String t) {
        if (s.isEmpty()) return true;
        int sLen = s.length();
        int tLen = t.length();
        if (sLen > tLen) return false;
        int cur1 = 0, cur2 = 0;
        while (cur1 < sLen && cur2 < tLen) {
            if (s.charAt(cur1) == t.charAt(cur2)) cur1++;
            cur2++;
        }
        return cur1 == sLen;
    }
}
